/*
** my_realloc.c for malloc in /home/dubois_e//Downloads/malloc/1
** 
** Made by remi dubois
** Login   <dubois_e@epitech.net>
** 
** Started on  Wed Jan 30 11:14:38 2013 remi dubois
** Last update Fri Feb  8 20:19:44 2013 remi dubois
*/

#include	"my_malloc.h"

void	*realloc(void *ptr, size_t taille)
{
  data	*tmp;
  void	*ret;

  if (ptr == NULL)
    return (malloc(taille));
  if (taille == 0)
    {
      free(ptr);
      return (NULL);
    }
  tmp = ptr - sizeof(*tmp);
  ret = malloc(taille);
  ret = memcpy((void *)ret, (void *)ptr, tmp->size);
  free(ptr);
  return (ret);
}

void	*calloc(size_t nmemb, size_t size)
{
  void	*ret;

  if (nmemb == 0 || size == 0)
    return (NULL);
  ret = malloc(size * nmemb);
  memset(ret , 0, (size * nmemb));
  return (ret);
}
